<?php
//require_once 'CoreReportingApiReference.php';
$profileId=$_SESSION['profileid'];

function getRows($results) {
    $table = 'Rows Of Data';

    if (count($results->getRows()) > 0) {
      $table .= '<table border="1" cellspacing="1" cellpadding="5">';

      // Print headers.
      $table .= '<tr>';

      foreach ($results->getColumnHeaders() as $header) {
        $table .= '<th>' . $header->name . '</th>';
      }
      $table .= '</tr>';

      // Print table rows.
      foreach ($results->getRows() as $row) {
        $table .= '<tr>';
          foreach ($row as $cell) {
            $table .= '<td>'
                   . htmlspecialchars($cell, ENT_NOQUOTES)
                   . '</td>';
          }
        $table .= '</tr>';
      }
      $table .= '</table>';

    } else {
      $table .= '<p>No results found.</p>';
    }

    return $table;
  }
  
function getRow($results, $table, $th1, $th2) {
$table;

if (count($results->getRows()) > 0) {
  $table .= '<table border="1" cellspacing="1" cellpadding="5">';


  $table .= '<tr>';

	$table .= '<th>'.$th1.'</th>';
	$table .= '<th>'.$th2.'</th>';

  $table .= '</tr>';
  foreach ($results->getRows() as $row) {
 
	$table .= '<tr>';
	$table .= '<td align="left">'
                      .$row[0].
                    '</td>';
			$table .= '<td align="right">'
                      .$row[1]. 
                    '</td>';
	$table .= '</tr>';
  }
  $table .= '</table>';

} else {
  $table .= '<p>No results found.</p>';
}

    return $table;
  }
?>

<div class = "row" >
<?php
echo "<h3>Composition</h3>";
/* $PVParams = array(
      'dimensions' => 'ga:date',
      
      
      'max-results' => '25');
$resultsPV = $analytics->data_ga->get(
       'ga:' . $profileId,
       '2014-11-01',
       '2014-11-15',
	   'ga:pageviews',
       $PVParams
	   );
$demo = getRows($resultsPV);
print $demo; */	   
?>

</div>
<div class = "row" >
<?php
//echo "<h3>Global Geographic Overview</h3>";
$GGParams = array(
      'dimensions' => 'ga:country',
      
      
      'max-results' => '25');
$resultsGG = $analytics->data_ga->get(
       'ga:' . $profileId,
       '2014-11-01',
       '2014-11-15',
	   'ga:sessions',
       $GGParams
	   );
	   
$th1 = "Negara";
$th2 = "Jumlah Kunjungan";
$table = "Global Geographic Overview";
$demo = getRow($resultsGG, $table, $th1, $th2);
print $demo; 
	   
?>
</div>

<div class = "row" >
<?php
echo "<h3>Observed Profiling</h3>";
/* $PPParams = array(
      'dimensions' => 'ga:pagePath',
      
      
      'max-results' => '25');
$resultsPP = $analytics->data_ga->get(
       'ga:' . $profileId,
       '2014-11-01',
       '2014-11-15',
	   'ga:pageviews',
       $PPParams
	   );
	   
$demo = getRows($resultsPP);
print $demo; */
	   
?>
</div>


